const sequelize = require('./src/config/database');

async function checkViewStructure() {
  try {
    console.log('正在查询videos_detail视图结构...');
    
    // 查询视图的列信息
    const columns = await sequelize.query(
      'SELECT column_name, data_type ' +
      'FROM information_schema.columns ' +
      "WHERE table_schema = 'new_bilibili' " +
      "AND table_name = 'videos_detail'",
      { type: sequelize.QueryTypes.SELECT }
    );
    
    console.log('\nvideos_detail视图列信息:');
    columns.forEach(column => {
      console.log(`- ${column.column_name} (${column.data_type})`);
    });
    
    // 尝试查询几行数据看看实际内容
    console.log('\n尝试查询前5行数据样本:');
    const sampleData = await sequelize.query(
      'SELECT * FROM videos_detail LIMIT 5',
      { type: sequelize.QueryTypes.SELECT }
    );
    
    if (sampleData.length > 0) {
      console.log('\n数据样本:');
      console.log(JSON.stringify(sampleData[0], null, 2));
    } else {
      console.log('\n视图中没有数据');
    }
    
    await sequelize.close();
  } catch (error) {
    console.error('查询失败:', error);
    await sequelize.close().catch(() => {});
  }
}

checkViewStructure();